import request from '@/utils/request'

export function getRoleList({ page, limit, name }) {
  return request({
    method: 'get',
    url: `/admin/acl/role/${page}/${limit}`,
    params: {
      roleName: name
    }
  })
}

//添加角色
export function addSave(data) {
  return request({
    method: 'post',
    url: `/admin/acl/role/save`,
    data
  })
}

//删除一个
export function delRole(id) {
  return request({
    method: 'delete',
    url: `/admin/acl/role/remove/${id}`
  })
}

//删除多个
export function delAll(data) {
  return request({
    method: 'delete',
    url: '/admin/acl/role/batchRemove',
    data
  })
}

//确认修改
export function roleUpdata(roleName, id) {
  return request({
    method: 'put',
    url: '/admin/acl/role/update',
    data: {
      deleted: false,
      roleName,
      id
    }
  })
}

//获取权限列表
export function getUserAclList(roleId) {
  return request({
    method: 'get',
    url: `/admin/acl/permission/toAssign/${roleId}`
  })
}

//提交分配权限
export function setUserAclList(roleId, permissionId) {
  return request({
    method: 'post',
    url: '/admin/acl/permission/doAssign',
    params: { roleId, permissionId }
  })
}
